package com.cskaoyan.day9;

public class RectangleAndSquare {
    public static void main(String[] args) {
        Rectangle rectangle = new Rectangle(2, 4);
        Square square = new Square(4);
        System.out.println("正方形周长:" + square.getCircumference() + "  ,  面积为: " + square.getArea());
        System.out.println("长方形周长:" + rectangle.getCircumference() + "  ,  面积为: " + rectangle.getArea());
    }
}

class Rectangle {
    private double longsize;
    private double widthsize;

    public Rectangle() {
    }

    public Rectangle(double longsize, double widthsize) {
        this.longsize = longsize;
        this.widthsize = widthsize;
    }

    public double getLongsize() {
        return longsize;
    }

    public void setLongsize(double longsize) {
        this.longsize = longsize;
    }

    public double getWidthsize() {
        return widthsize;
    }

    public void setWidthsize(double widthsize) {
        this.widthsize = widthsize;
    }

    public double getArea() {
        return (widthsize * longsize);
    }

    public double getCircumference() {
        return 2 * (widthsize + longsize);
    }
}

class Square {
    private double sideLength;

    public Square() {
    }

    public Square(double sideLength) {
        this.sideLength = sideLength;
    }

    public double getSideLength() {
        return sideLength;
    }

    public void setSideLength(double sideLength) {
        this.sideLength = sideLength;
    }

    public double getArea() {
        return sideLength * sideLength;
    }

    public double getCircumference() {
        return 4 * sideLength;
    }
}
